import { ApiProperty } from '@nestjs/swagger';
import { IsEmail, IsEnum, IsOptional, IsString, MinLength } from 'class-validator';
import { Role } from '../../auth/enums/role.enum';

export class UpdateUserDto {
  @ApiProperty({ description: '用户名', example: 'johndoe', required: false })
  @IsOptional()
  @IsString({ message: '用户名必须是字符串' })
  username?: string;

  @ApiProperty({ description: '邮箱', example: 'john@example.com', required: false })
  @IsOptional()
  @IsEmail({}, { message: '邮箱格式不正确' })
  email?: string;

  @ApiProperty({ description: '密码', example: 'password123', required: false })
  @IsOptional()
  @IsString({ message: '密码必须是字符串' })
  @MinLength(6, { message: '密码长度不能少于6个字符' })
  password?: string;

  @ApiProperty({ description: '用户状态', enum: ['active', 'inactive'], required: false })
  @IsOptional()
  @IsString({ message: '状态必须是字符串' })
  status?: string;

  @ApiProperty({ description: '用户角色', enum: Role, required: false })
  @IsOptional()
  @IsEnum(Role, { message: '角色必须是有效的枚举值' })
  role?: Role;
}